//
//  ViewController.m
//  DKShortVideo
//
//  Created by Keer_LGQ on 2018/3/29.
//  Copyright © 2018年 DK. All rights reserved.
//

#import "DKRootViewController.h"
#import "DKRouterManger.h"

@interface DKRootViewController ()

@end

@implementation DKRootViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"DK";
    CGFloat width = [[UIScreen mainScreen] bounds].size.width;

    UIButton *btnPlay = [UIButton buttonWithType:UIButtonTypeCustom];
    [btnPlay addTarget:self action:@selector(playVideo:) forControlEvents:UIControlEventTouchUpInside];
    [btnPlay setBackgroundColor:[UIColor redColor]];
    [btnPlay setTitle:@"看视频" forState:UIControlStateNormal];
    [btnPlay setFrame:CGRectMake(0, 0, 150, 50)];
    [btnPlay setCenter:CGPointMake(width/2, 150)];
    [self.view addSubview:btnPlay];
 
    UIButton *btnRecord = [UIButton buttonWithType:UIButtonTypeCustom];
    [btnRecord addTarget:self action:@selector(recordVideo:) forControlEvents:UIControlEventTouchUpInside];
    [btnRecord setBackgroundColor:[UIColor redColor]];
    [btnRecord setTitle:@"录视频" forState:UIControlStateNormal];
    [btnRecord setFrame:CGRectMake(0, 0, 150, 50)];
    [btnRecord setCenter:CGPointMake(width/2, 350)];
    [self.view addSubview:btnRecord];

}

#pragma mark - play control
- (void)playVideo:(id)sender
{
    // http://baobab.wdjcdn.com/14559682994064.mp4
    // prog_index.m3u8
    // http://devimages.apple.com.edgekey.net/streaming/examples/bipbop_4x3/gear2/fileSequence1.ts
    BOOL isNet = NO;
    NSString *netUrl = isNet?@"http://devimages.apple.com.edgekey.net/streaming/examples/bipbop_4x3/gear2/prog_index.m3u8":@"0001.mp4";
    [[DKRouterManger shareInstance] onPreviewVideo:netUrl isShow:YES];
}

- (void)recordVideo:(id)sender
{
    [[DKRouterManger shareInstance] onRecordPreview:YES];
}

@end
